/*
 * JPanelTextField.java
 *
 * Created on 11 de octubre de 2008, 22:10
 */

package es.atareao.alejandria.gui;

import java.awt.Dimension;
import javax.swing.event.DocumentEvent;
import javax.swing.event.DocumentListener;

/**
 *
 * @author  Propietario
 */
public class JPanelTextField extends javax.swing.JPanel {

    /** Creates new form JPanelTextField */
    public JPanelTextField() {
        initComponents();
        this.jTextField1.getDocument().addDocumentListener(new DocumentListener() {
            @Override
            public void changedUpdate(DocumentEvent e) {
                // text was changed
                firePropertyChange("value",null,e.getDocument().toString());
            }
            @Override
            public void removeUpdate(DocumentEvent e) {
                // text was deleted
                firePropertyChange("value",null,e.getDocument().toString());
            }
            @Override
            public void insertUpdate(DocumentEvent e) {
                // text was inserted
                firePropertyChange("value",null,e.getDocument().toString());
            }
        });        
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jLabel1 = new javax.swing.JLabel();
        jPanel1 = new javax.swing.JPanel();
        jTextField1 = new javax.swing.JTextField();

        setMaximumSize(new java.awt.Dimension(32767, 30));
        setMinimumSize(new java.awt.Dimension(0, 30));
        setPreferredSize(new java.awt.Dimension(50, 30));
        setLayout(new javax.swing.BoxLayout(this, javax.swing.BoxLayout.X_AXIS));

        jLabel1.setText("jLabel1");
        jLabel1.setMaximumSize(new java.awt.Dimension(2147483647, 25));
        jLabel1.setMinimumSize(new java.awt.Dimension(0, 25));
        jLabel1.setPreferredSize(new java.awt.Dimension(10, 25));
        add(jLabel1);

        jPanel1.setMaximumSize(new java.awt.Dimension(10, 25));
        jPanel1.setMinimumSize(new java.awt.Dimension(10, 25));
        jPanel1.setPreferredSize(new java.awt.Dimension(10, 25));

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 10, Short.MAX_VALUE)
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGap(0, 25, Short.MAX_VALUE)
        );

        add(jPanel1);

        jTextField1.setMaximumSize(new java.awt.Dimension(2147483647, 25));
        jTextField1.setMinimumSize(new java.awt.Dimension(0, 25));
        jTextField1.setPreferredSize(new java.awt.Dimension(60, 25));
        add(jTextField1);
    }// </editor-fold>//GEN-END:initComponents


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JLabel jLabel1;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JTextField jTextField1;
    // End of variables declaration//GEN-END:variables
    private String _label;
    private String _value;
    private int _labelSize;

    public String getLabel() {
        this._label=this.jLabel1.getText();
        return _label;
    }

    public void setLabel(String label) {
        this._label = label;
        this.jLabel1.setText(label);
    }

    public String getValue() {
        this._value=this.jTextField1.getText();
        return _value;
    }

    public void setValue(String value) {
        this._value = value;
        this.jTextField1.setText(value);
    }

    public int getLabelSize() {
        this._labelSize=this.jLabel1.getWidth();
        return _labelSize;
    }

    public void setLabelSize(int labelSize) {
        this._labelSize = labelSize;
        this.jLabel1.setMaximumSize(new Dimension(labelSize,25));
        this.jLabel1.setMinimumSize(new Dimension(labelSize,25));
        this.jLabel1.setPreferredSize(new Dimension(labelSize,25));
    }
}
